package com.sky.utils;

import com.sky.constant.MessageConstant;
import com.sky.context.BaseContext;
import com.sky.dto.UserThredDTO;
import com.sky.exception.UserNotLoginException;

/**
 * @BelongsProject: sky-take-out
 * @BelongsPackage: com.sky.utils
 * @Author: XieMingHui
 * @CreateTime: 2023-11-20  18:27
 * @Description: 判断是否登录获取线程中的当前登录的用户信息
 * @Version: 1.0
 */
public class UserThreadUtil {

    /**
     * 获取线程空间存储的用户
     *
     * @author: XieMingHui
     * @date: 23/11/20 12:07:53
     * @param: []
     * @return: void
     **/
    public static UserThredDTO getThread() {
        UserThredDTO userThredDTO = BaseContext.getCurrentId();
        if(userThredDTO==null){
            throw new UserNotLoginException(MessageConstant.USER_NOT_LOGIN);
        }
        return userThredDTO;
    }
}
